<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ary(与...有关)</title>
</head>
<body>
<h4>
    Creates a function that accepts up to n arguments, ignoring any additional arguments.
    Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).
</h4>
<h4>
    slice(start ,end) 方法可从已有的数组中返回选定的元素,这是一个全新的子数组
    返回一个新的数组，包含从 start 到 end （不包括该元素）的 arrayObject 中的元素
    如果不传入end,默认为数组结尾
    ...对象扩展符,遍历数组
</h4>
<script type="text/javascript">
    const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
    //传入函数对比最大值,传入2确定了slice参数为(0,2)
    const firstTwoMax = ary(Math.max, 2);
    console.log([[2, 6, "a"], [8, 6, 4], [10]].map(x => firstTwoMax(...x)))
</script>
</body>
</html>